import { obtainCourseReferral } from '../../.../../../../../config/api'
import * as actionTypes from './actionTypes';

const getCourseReferral = (data) => ({
	type: actionTypes.Acquire_Course_Referral,
	data
});
const updateWrapSwitchReferral = (data) => ({
	type: actionTypes.Switch_Course_Flag,
	data
});
const getHandlerClickCourseCheck = (data) => ({
	type: actionTypes.Handler_Click_Course_Check,
	data
});
const getHandlerQrCodeShow = (data) => ({
	type: actionTypes.Handler_QrCode_Show,
	data
});

// 获取 课程介绍
export const acquireCourseReferral = ( open_id, union_id ) => {
	return async (dispatch) => {
		const courseReferral = await obtainCourseReferral( open_id, union_id )
		console.log(courseReferral.data, '获取 课程介绍 数据')
		dispatch(getCourseReferral(courseReferral.data));
	}
};
// 获取 切换课程介绍
export const updateWrapSwitchStatus = (state) => {
	return async (dispatch) => {
		dispatch(updateWrapSwitchReferral(state));
	}
};
// 选择课程
export const handlerClickCourseCheck = (state) => {
	return async (dispatch) => {
		dispatch(getHandlerClickCourseCheck(state));
	}
};
// 课程二维码显示
export const handlerQrCodeShow = (state) => {
	return async (dispatch) => {
		dispatch(getHandlerQrCodeShow(state));
	}
};